/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.finance.model;

import cn.hutool.core.util.NumberUtil;
import com.medusa.gruul.finance.api.entity.FinanceAccount;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * The type Api finance account vo.
 *
 * @description: 小程序端个人佣金详情
 * @author: alan
 * @date: 2019 /11/5 21:29
 */
@Data
@ApiModel(value = "小程序端个人佣金详情")
public class ApiFinanceAccountVo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 累计佣金
     */
    @ApiModelProperty(value = "累计佣金")
    private BigDecimal brokerageTotal;

    /**
     * 可提现佣金
     */
    @ApiModelProperty(value = "可提现佣金")
    private BigDecimal brokerage;

    /**
     * 已提现佣金
     */
    @ApiModelProperty(value = "已提现佣金")
    private BigDecimal withdrawalBrokerage;

    /**
     * 待审核佣金
     */
    @ApiModelProperty(value = "待审核佣金")
    private BigDecimal waitReviewedBrokerage;

    /**
     * 预计佣金（待结算佣金）
     */
    @ApiModelProperty(value = "预计佣金（待结算佣金）")
    private BigDecimal brokerageFrozen;


    /**
     * To vo api finance account vo.
     *
     * @param account             the account
     * @param withdrawalBrokerage the withdrawal brokerage
     * @return the api finance account vo
     */
    public static ApiFinanceAccountVo toVo(FinanceAccount account, BigDecimal withdrawalBrokerage) {
        ApiFinanceAccountVo apiFinanceAccountVo = new ApiFinanceAccountVo();
        apiFinanceAccountVo.setBrokerageTotal(NumberUtil.sub(account.getBrokerageTotal(), account.getBrokerage()));
        apiFinanceAccountVo.setBrokerage(account.getBrokerage());
        apiFinanceAccountVo.setBrokerageFrozen(account.getBrokerageFrozen());
        apiFinanceAccountVo.setWithdrawalBrokerage(withdrawalBrokerage);
        return apiFinanceAccountVo;
    }
}
